package com.it.you.base.optional;

import com.it.you.pojo.Student;

import java.util.Optional;

public class OptionalTest1 {

    public static void main(String[] args) {

        Student student = new Student();
        //student.setName("youhui");
        if (Optional.ofNullable(student.getName()).isPresent()) {
            System.out.println("姓名不为空");
        }
//        Date birthDate = student.getBirthDate();
//        System.out.println(birthDate);
//        System.out.println(Optional.of(birthDate));//null point exception

        int age = student.getAge();
        System.out.println(age);
        System.out.println(Optional.of(age));
        System.out.println(Optional.of(age).empty().isPresent());
    }
}
